<?php
namespace app\admin\validate;

use think\Validate;

class BannerValidate extends Validate
{
    protected $rule =   [
        'id'            => 'require|number',
        'page'          => 'require|number',
        'limit'         => 'require|number',
        'title'         => 'require|length:1,30',
        'img'           => 'require|image',
        'sort'          => 'require|number',
        'is_show'       => 'require|number',
    ];
    
    protected $message  =   [
        'id.require'            => 'ID必须',
        'id.number'             => 'ID必须是数字',
        'page.require'          => '页数不能为空',
        'page.number'           => '页数数据类型错误',
        'limit.require'         => '条数不能为空',
        'limit.number'          => '条数数据类型错误',
        'title.require'         => '轮播图标题不能为空',
        'title.length'          => '轮播图标题长度错误',
        'sort.require'          => '排序值不能为空',
        'sort.number'           => '排序值数据类型错误',
        'img.require'           => '图片不能为空',
        'img.image'             => '图片上传类型错误',
        'is_show.require'       => '状态不能为空',
        'is_show.number'        => '状态数据类型错误',
    ];
    
    protected $scene = [
        'show'         => ['id'],
        'list'         => ['page', 'limit'],
        'add'          => ['title', 'img', 'sort'],
        'edit'         => ['id', 'title', 'sort'],
        'editImg'      => ['id', 'title', 'img', 'sort'],
    ];
}